package com.lzp.appexp;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.DownloadListener;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;

import androidx.annotation.Nullable;

import com.base.BaseActivity;

/**
 * @describe:
 * @Author: lixiaopeng
 * @Date: 2020-01-21
 */
public class TestActivity extends BaseActivity {

    private static final String TAG = "TestActivity";

    private WebView mWebView;

    private View iv = null;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
    }

    @Override
    public void findView() {
        iv = findViewById(R.id.iv);
    }

    @Override
    public void initView() {
        ValueAnimator animator = ValueAnimator.ofFloat(0,300);
        animator.setDuration(1000L);
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                startAnimation();
            }
        });
        animator.start();
        iv.postDelayed(new Runnable() {
            @Override
            public void run() {
                try {
                    Log.d(TAG, "run: "+System.currentTimeMillis());
                    Thread.sleep(2000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },500);

    }

    private void startAnimation() {
        ValueAnimator animator = ValueAnimator.ofFloat(0,300);
        animator.setDuration(3000L);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float animatedValue = (float) animation.getAnimatedValue();
                iv.setTranslationY(animatedValue);
                Log.d(TAG, "onAnimationUpdate: "+System.currentTimeMillis());
            }
        });
        animator.start();
    }
}